package saxon.util;

import org.apache.commons.dbcp2.BasicDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;

public class dbcpUtil {
   private static DataSource dataSource=null;
    static {
        InputStream input = JdbcUtil.class.getClassLoader ().getResourceAsStream ("dbcp.properties");
        Properties properties = new Properties ();
        try {
            properties.load (input);
            dataSource = BasicDataSourceFactory.createDataSource (properties);
        } catch (Exception e) {
            e.printStackTrace ();
        }
    }

    public static Connection getConnection () throws SQLException {
        return dataSource.getConnection ();
    }

}
